package com.aifund.app.service.impl;

import com.aifund.app.service.UserBindExchangeService;
import com.aifund.common.dao.UserBindExchangeDao;
import com.aifund.common.entity.AiUserBindExchange;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserBindExchangeServiceImpl implements UserBindExchangeService {

    @Autowired
    UserBindExchangeDao userBindExchangeDao;

    @Override
    public AiUserBindExchange getUserBindExchange(Long userId, Long exchangeId) {
        return userBindExchangeDao.getAllByAiUserIdAndAiExchangeId(userId,exchangeId).get(0);
    }

    @Override
    public AiUserBindExchange getByExchangeIdAndApiKey(Long exchangeId, String apiKey) {
        return userBindExchangeDao.getByApiKeyAndAiExchangeId(apiKey,exchangeId);
    }

    @Override
    public List<AiUserBindExchange> getByUserIdAndExchangeId(Long userId, Long exchangeId) {
        List<AiUserBindExchange> userBindExchanges = userBindExchangeDao.getAllByAiUserIdAndAiExchangeId(userId, exchangeId);
        return  userBindExchanges;
    }

    @Override
    public void save(AiUserBindExchange userBindExchange) {
        userBindExchangeDao.save(userBindExchange);
    }


}
